<?php
/**
 * Created by PhpStorm.
 * User: landiyu
 * Date: 15-02-22
 * Time: 00:01
 */

namespace Home\Widget;
use Think\Action;

class ContactWidget extends Action {
    public function demo(){

        $cate = session('current');
        //echo $cate;

        //跳转到对应的模块
        $str = 'SELECT * FROM `sdg_category` WHERE id = '.$cate.' AND `status` = 1';
        //echo $str;
        $Model = M();
        $rs = $Model->query($str);

        //print_r($rs);
        echo($rs[0]['template_index']);

        //exit();

        switch($cate)
        {
            case 2:
                $Data = M('Data'); // 实例化Data数据对象
                import('ORG.Util.Page');// 导入分页类
                //$count      = $Data->where($map)->count();// 查询满足要求的总记录数 $map表示查询条件
                $count      = $Data->count();// 查询满足要求的总记录数 $map表示查询条件
                $Page       = new \Think\Page($count, 10);// 实例化分页类 传入总记录数
                $show       = $Page->show();// 分页显示输出
                // 进行分页数据查询
                //$list = $Data->where($map)->order('create_time')->limit($Page->firstRow.','.$Page->listRows)->select();
                $list = $Data->order('create_time')->limit($Page->firstRow.','.$Page->listRows)->select();
                $this->assign('list',$list);// 赋值数据集
                $this->assign('page',$show);// 赋值分页输出

                $this->display('Contact/demo');

                break;
            //case 39:


                //$this->assign('menuCate', $cate);
                //$this->display('Contact/demo3');


                //$this->assign('menuCate', $cate);
                //$this->display('Contact/demo2');

                //break;
            default:

                $this->assign('menuCate', $cate);
                $this->display($rs[0]['template_index']);

                break;
        }


    }
}